package com.example.jhweather.Module;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.jhweather.Base.BaseActivity;
import com.example.jhweather.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class LuachActivity extends BaseActivity {

    @BindView(R.id.Btn_jump)
    Button btn_jump;
    @BindView(R.id.Img_luachPage)
    ImageView img_leachPage;

    private Handler handler = new Handler();
    private final Runnable runnable = this::intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_luach);

        initView();

        initData();

        //绑定控件
        ButterKnife.bind(this);

        //等待三秒跳转
        waittologin();
    }

    private void initView() {
        img_leachPage = findViewById(R.id.Img_luachPage);
    }

    private void initData() {
        //img_leachPage.setBackground(getDrawable(R.drawable.ic_launcher_background));
        Glide
                .with(this)
                .load("http://photocq.photo.store.qq.com/psc?/V14LlDz03d2tsE/bmxpj0TIaxwnN1NLYawL3PzoWmfBaZ0.WKCAgpAyrsuahkYqKND.8I8bKCIhIJp6smdYl4dOWnngKdm32u26ueXFzvV9V0u7Cbpnt58Mji4!/b&bo=sAQgA7AEIAMRGS4!&rf=viewer_4")
                .error(R.drawable.psc)
                .thumbnail(0.2f)
                .into(img_leachPage);
    }

    /**
     * 跳转到主页面
     */
    private void intent(){
        Intent intent = new Intent(LuachActivity.this,MainActivity.class);
        startActivity(intent);
        finish();
    }

    @OnClick(R.id.Btn_jump)
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.Btn_jump:
                intent();
                handler.removeCallbacks(runnable);
                break;
            default:
                break;
        }
    }

//    private void clicktologin() {
//        btn_jump.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
//    }

    private void waittologin() {
        handler.postDelayed(runnable, 3000);
    }
}